const requestIp = require('request-ip');
function getClientIpAndPort(request) {
  const ip = requestIp.getClientIp(request).replace('::ffff:', '');
  const port = 'remotePort' in request.socket ? request.socket.remotePort : null

  return { ip: ip ?? '', port: port ?? null }
}

module.exports = {
  getClientIpAndPort
}
